<template>
	<view class="pt160r pl50r pr50r">
		<view class="f60r col111734 mb80r">
			Hi，欢迎回来
			<view class="f30r">
				新山雀壹B端
			</view>
		</view>
		<view class="">
			<input type="text" placeholder="请输入用户名" v-model="phone"
				class="lh90r pl28r pr28r backColF2f3f5 borRad45r h90r f21r mb30r"
			>
			<input type="password" placeholder="请输入密码" v-model="password"
				class="lh90r pl28r pr28r backColF2f3f5 borRad45r h90r f21r mb60r"
			>
		</view>
		<view class="lh90r teAliCenter borRad45r f30r colFff backCol64aeb4"
			@click="cliSignIn"
		>
			登录
		</view>
	</view>
</template>
<script>
import { loginTeaAdmin } from '@/utils/api.js'
export default {
	data() {
		return {
			phone: '',
			password: ''
		}
	},
	methods: {
		cliSignIn() {
			if(!this.phone) return uni.showToast({ icon: 'none', title: '请输入用户名' })
			if(!this.password) return uni.showToast({ icon: 'none', title: '请输入密码' })
			loginTeaAdmin({
				phone: this.phone,
				password: this.password
			}).then(res1 => {
				uni.setStorage({
					key: 'token', data: res1.data.token,
					success:res2 => {
						uni.setStorage({
							key: 'userInfo', data: res1.data,
							success:res3 => {
								// uni.switchTab({
								// 	url: '/pages/personalCenter/index'
								// })
								uni.navigateBack();
							}
						})
					}
				})
			})
		}
	}
}
</script>
<style>
</style>